<!DOCTYPE html>
<html>
<head>
    <include file="Public/head"/>
</head>

<body>
<header id="header">
    <div class="header_l header_return"> <a class="ico_10" href="javascript:history.go(-1);"> 返回 </a> </div>
    <h1> 所有分类页</h1>
    <div class="header_r header_search"> <a class="ico_03"  onClick="showSearch()"> 搜索 </a> </div>
    <div id="search_box">
        <div class="search_box">
            <form method="get" action="{:U('Goods/index')}" name="searchForm" id="searchForm_id">
                <input placeholder="请输入商品名称" name="title" type="text" id="keywordBox" />
                <button class="ico_07" type="submit" onclick="return check('keywordBox')"> </button>
            </form>
        </div>
        <a class="ico_08" onClick="closeSearch()"></a> </div>
</header>

<div class="clist">
    <ul>
        <volist name="categorys" id="cate">
            <li class="crow level1">
                <a href="{:U('Goods/index',array('category'=>$cate['id']))}">
                    <div class="crow_row">
                        <div class="crow_icon"> <img src="http://{:C('DOMAIN')}{:get_cover($cate['cover_id'],'path')}" onerror="this.src='__IMG__/class-logo.png'" style="width: 3.3rem; height: 3.3rem"/> </div>
                        <div class="crow_title">  <span>{$cate.title}</span>  </div>
                        <!--<div class="crow_arrow"> <img src="__IMG__/ico_11.png"> </div>-->
                        <div>&nbsp;</div>
                    </div>
                </a>
            </li>
            <if condition="isset($cate['child'])">
                <ul  class="clist clist_sub clearfix" style="opacity: 1; display: none;">
                    <li class="crow">
                        <volist name="cate['child']" id="cate_2">
                            <div class="crow_item crow_item_clear"> <a href="{:U('Goods/index',array('category'=>$cate_2['id']))}">{$cate_2.title}</a> </div>
                        </volist>
                    </li>
                </ul>
            </if>
        </volist>
    </ul>
</div>

<script type="text/javascript">
    /*头部搜索点击关闭或者弹出搜索框*/
    function showSearch( ){
        document.getElementById("search_box").style.display="block";
    }
    function closeSearch(){
        document.getElementById("search_box").style.display="none";
    }
    /* 搜索验证 */
    function check(Id){
        var strings = document.getElementById(Id).value;
        if(strings.replace(/(^\s*)|(\s*$)/g, "").length == 0){
            return false;
        }
        return true;
    }

    (function($) {
        var btn_up = new Image(), btn_down = new Image();
        btn_up.src = "__IMG__/ico_12.png";
        btn_down.src = "__IMG__/ico_11.png";
        var Menu = {
            // 初始化事件
            initEvent : function() {
                $().ready(
                        function() {
                            $("div.clist").click(function(e) {
                                Menu.router(e);
                            });
                            $("#allClass").click(function(e) {
                                Menu.showMenu1();
                            });
                            $(window).on(
                                    "hashchange",
                                    function(e) {
                                        var name = decodeURIComponent(location.hash
                                                .replace(/^#/, ""));
                                        if (name != "") {
                                            Menu.showMenu3(name);
                                        }else{
                                            Menu.showMenu1();
                                        }
                                    });
                        });
            },
            // 事件分发路油
            router : function(_event) {
                var target = $(_event.target || _event.srcElement);
                var _tar = target.closest(".level1");

                // 显示二级菜单
                if (_tar.length > 0) {
                    Menu.showMenu2(_tar);
                    /*var _gp = target.closest(".crow_row");// 点击事件对应此行的祖父级节点
                     var _top = _gp.offset().top;
                     setTimeout(function(){
                     if (_top > 100) {
                     window.scroll(0, _gp.offset().top);
                     } else {
                     window.scroll(0, _gp.offset().top - 50);
                     }
                     },15)*/
                    return;
                }
            },
            // 显示一级菜单
            showMenu1 : function() {
                $("#contentsub").hide();
                $("#content").show();
            },
            // 显示二级菜单
            showMenu2 : function($curMenuDom) {
                var next = $curMenuDom.next("ul");
                if (next.css("display") == "none") {
                    //$("ul.clist_sub").hide();
                    //$("div.crow_arrow").each(function(i, dom) {
                    //	$(dom).html(btn_down.cloneNode(true));
                    //});
                    next.css("opacity", "0").show().animate({
                        opacity : 1
                    }, 500);
                    //next.show();
                    $("div.crow_arrow", $curMenuDom).html(btn_up.cloneNode(true));
                } else {
                    next.hide();
                    $("div.crow_arrow", $curMenuDom).html(btn_down.cloneNode(true));
                }
            },

        }
        window.Menu = Menu;
        Menu.initEvent();// 初始化事件
    })($);
</script>
</body>
</html>
